/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.FaceFeature;
import com.yami.shop.dao.FaceFeatureMapper;
import com.yami.shop.service.FaceFeatureService;
import com.yami.shop.common.util.PageParam;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 五官资源服务实现
 * @author AI Assistant
 */
@Service
public class FaceFeatureServiceImpl extends ServiceImpl<FaceFeatureMapper, FaceFeature> implements FaceFeatureService {

    @Autowired
    private FaceFeatureMapper faceFeatureMapper;

    @Override
    public List<FaceFeature> listByFeatureTypeAndStatus(Integer featureType, Integer status) {
        return this.list(new LambdaQueryWrapper<FaceFeature>()
                .eq(featureType != null, FaceFeature::getFeatureType, featureType)
                .eq(status != null, FaceFeature::getStatus, status));
    }

    @Override
    public List<FaceFeature> listByStatus(Integer status) {
        return this.list(new LambdaQueryWrapper<FaceFeature>()
                .eq(status != null, FaceFeature::getStatus, status));
    }

    @Override
    public List<FaceFeature> listByFeatureTypesAndStatus(List<Integer> featureTypes, Integer status) {
        return this.list(new LambdaQueryWrapper<FaceFeature>()
                .in(featureTypes != null && !featureTypes.isEmpty(), FaceFeature::getFeatureType, featureTypes)
                .eq(status != null, FaceFeature::getStatus, status));
    }

    @Override
    public void saveFaceFeature(FaceFeature faceFeature) {
        faceFeatureMapper.insert(faceFeature);
    }

    @Override
    public void updateFaceFeature(FaceFeature faceFeature) {
        faceFeatureMapper.updateById(faceFeature);
    }

    @Override
    public void deleteFaceFeature(Long featureId) {
        faceFeatureMapper.deleteById(featureId);
    }

    @Override
    public IPage<FaceFeature> pageByFeatureTypeAndStatus(PageParam<FaceFeature> page, Integer featureType, Integer status) {
        return faceFeatureMapper.selectPage(page, new LambdaQueryWrapper<FaceFeature>()
                .eq(featureType != null, FaceFeature::getFeatureType, featureType)
                .eq(status != null, FaceFeature::getStatus, status));
    }
}